"""
@-*- coding: utf-8 -*-
@ python: 3.12.3
@ 创建者: JacksonCode
@ 创建时间: 2025-10-13
"""
# 某个网站，多个哈希加密， 写一个代码，动态传入算法并算出值
import hashlib


def hash(data, s):
    # if s == 'md5':
    #     return hashlib.md5(data.encode('utf-8')).hexdigest()
    # if s == 'sha1':
    #     return hashlib.sha1(data.encode('utf-8')).hexdigest()
    # if s == 'sha224':
    #     return hashlib.sha224(data.encode('utf-8')).hexdigest()
    # if s == 'sha256':
    #     return hashlib.sha256(data.encode('utf-8')).hexdigest()
    obj = hashlib.new(s)
    obj.update(data.encode('utf-8'))
    return obj.hexdigest()


if __name__ == '__main__':
    ret = hash("123456", "md5")
    print(ret)
